﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data;
using System.Linq;
using WpfApplication1.TaskModule;
using WpfApplication1.ContactModule;

namespace WpfApplication1
{
    public class ItemsDbContext : DbContext, IContactItemsRepository,ITaskItemsRepository
    {
        public DbSet<ContactItem> ContactItems { get; set; }

        public IEnumerable<ContactItem> Contacts
        {
            get { return ContactItems.ToList(); }
        }

        public ContactItem Remove(ContactItem entity)
        {
           return ContactItems.Remove(entity);
        }

        public bool HasUnsavedChanges()
        {
            return this.ChangeTracker.Entries().Any(e => e.State == EntityState.Modified);
        }
        public DbSet<TaskItem> TaskItems { get; set; }

        public IEnumerable<TaskItem> Tasks
        {
            get { return TaskItems.ToList(); }
        }

        public TaskItem Remove(TaskItem entity)
        {
            return TaskItems.Remove(entity);
        }

    }
}
